/*
 * @Description: 
 * @Author: fhw
 * @Date: 2023-02-24 15:29:57
 */
/**
 * 把路由转换成map 类型
 * @param {*} obj
 * @param {*} map
 */
export default function getMap(obj: any, map: any = {}) {
	// let map = {}
	if (obj.redirect) {
		map[obj.name] = {
			component: obj.component,
			redirect: obj.redirect,
			path: obj.path,
			noCache: obj.noCache,
			noKey: obj.noKey,
			biz: obj.biz,
			name: obj.name,
			alwaysShow: obj.meta?.alwaysShow,
			title: obj.meta?.title ?? '',
			keepAlive: obj.meta?.keepAlive,
		}
	} else {
		map[obj.name] = {
			name: obj.name,
			component: obj.component,
			path: obj.path,
			noCache: obj.noCache,
			noKey: obj.noKey,
			biz: obj.biz,
			alwaysShow: obj.meta?.alwaysShow,
			keepAlive: obj.meta?.keepAlive,
			title: obj.meta?.title ?? '',
		}
	}

	if (obj.children && obj.children.length > 0) {
		obj.children.forEach((element: any) => {
			getMap(element, map)
		})
	}

	return map
}
